<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.model.Imgadv"%>
<%@page import="com.dao.CommonDAO"%>
<%@page import="com.util.Info"%>
<%@page import="com.model.Goods"%>
<%@page import="com.util.PageManager"%>
<%@page import="com.model.Ppinfo"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
  <head>
    <base href="<%=basePath%>">
    
    <title>图书借阅管理系统</title>
    <meta charset="utf-8" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
	<!-- //Custom Theme files -->
	<link href="css/bootstrap.css" type="text/css" rel="stylesheet" media="all">
	<link href="css/style.css" type="text/css" rel="stylesheet" media="all">
	<!-- js -->
	<script src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/bootstrap-3.1.1.min.js"></script>
	<script src="js/imagezoom.js"></script>
	<!-- //js -->
	<!-- cart -->
	<script src="js/simpleCart.min.js"> </script>
	<!-- cart -->
	<!-- FlexSlider -->
	<script defer src="js/jquery.flexslider.js"></script>
	<link rel="stylesheet" href="css/flexslider.css" type="text/css" media="screen" />
  </head>
    <%
    CommonDAO dao = (CommonDAO)Info.getDao(request,"CommonDAO");  
    ArrayList<Ppinfo> plist = (ArrayList<Ppinfo>)dao.findByHql("from Ppinfo where delstatus='0'");
    String hql = " from Goods where 1=1 and delstatus='0' ";
				 String url = "/bookborrowssh/index.jsp?1=1";
				 String key = request.getParameter("key")==null?"":request.getParameter("key");//编号
				 String key1 = request.getParameter("key1")==null?"":request.getParameter("key1");
				 String key2 = request.getParameter("key2")==null?"":request.getParameter("key2");//小类
				 String key3 = request.getParameter("key3")==null?"":request.getParameter("key3");//排行
				 String key4 = request.getParameter("key4")==null?"":request.getParameter("key4");//出版社
				 String key5 = request.getParameter("key5")==null?"":request.getParameter("key5");//书名
				 String key6 = request.getParameter("key6")==null?"":request.getParameter("key6");//作者
				 String f = request.getParameter("f");
				 if(1==1)
				 {
				 key = Info.getUTFStr(key);
				 key5 = Info.getUTFStr(key5);
				 key6 = Info.getUTFStr(key6);
				 }
				 
				 if(!key.equals(""))
				 {
					 hql+=" and goodno like'%"+key+"%'";
				 url+="&key="+key;
				 }
				 if(!key1.equals(""))
				 {
					 hql+=" and (fid ='"+key1+"')";
				 	url+="&key1="+key1;
				 }
				 if(!key2.equals(""))
				 {
					 hql+=" and (sid ='"+key2+"')";
				 url+="&key2="+key2;
				 }
				 if(!key4.equals(""))
				 {
					 hql+=" and goodpp='"+key4+"'";
				 url+="&key4="+key4;
				 }
				 if(!key5.equals(""))
				 {
					 hql+=" and goodname like'%"+key5+"%'";
				 url+="&key5="+key5;
				 }
				 if(!key6.equals(""))
				 {
					 hql+=" and author like'%"+key6+"%'";
				 url+="&key6="+key6;
				 }
				 if(!key3.equals(""))
				 {
				 hql+=" order by cs desc";
				 url+="&key3="+key3;
				 }else{
				 hql+=" order by id desc";
				 }
				 
				 System.out.println("sql==="+hql);
				 %>
  <body>
  	<jsp:include page="top.jsp"></jsp:include>
    
					<div align="right" style="background-color: #FFAA25;height: 40px">
						<form class="navbar-form" action="index.jsp?f=f" method="post">
							<input type="text" placeholder="图书编号 :" id="key" name="key" value="<%=key %>" class="form-control">
							<input type="text" placeholder="图书名称 :" id="key5" name="key5"  value="<%=key5 %>" class="form-control">
							<input type="text" placeholder="作者 :" id="key6" name="key6"  value="<%=key6 %>" class="form-control">
							<select class="form-control" name="key4" style="width:180px;margin-top: 2px;">
							  <option value="">请选择出版社</option>
							  <%for(Ppinfo ppp:plist){ %>
							  <option value="<%=ppp.getId() %>" <%=ppp.getId().toString().equals(key4)?"selected":"" %>><%=ppp.getPpname() %></option>
							  <%} %>
							</select>
							<button type="submit" class="btn btn-default" aria-label="Left Align">
								查询
							</button>
						</form>
					</div>		


<div class="collpse tabs">
		<div class="container">
			<div class="panel-group collpse" id="accordion" role="tablist" aria-multiselectable="true">
				<div class="panel panel-default">
					<div class="panel-heading" role="tab" id="headingOne">
						<h4 class="panel-title">
							<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
							  图书列表
							</a>
						</h4>
					</div>
					<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
						<div class="panel-body">

	<!--gallery-->
	
			<div class="gallery-grids">
				
				<%
				 
				  PageManager pageManager = PageManager.getPage("/bookborrowssh/index.jsp?1=1",20, request);
			      pageManager.doList(hql);
			      PageManager bean= (PageManager)request.getAttribute("page");
			      ArrayList<Goods> list=( ArrayList<Goods>)bean.getCollection();
			    int i=0;
				for(Goods goods:list){
				i++;
				if(i==9){break;}
				%>
				<div class="col-md-3 gallery-grid" >
					<a href="good.jsp?gid=<%=goods.getId() %>"><img src="upfile/<%=goods.getFilename() %>" style="height: 305px;"   class="img-responsive"  alt=""/>
						<div class="gallery-info">
							<a class="shop" href="good.jsp?gid=<%=goods.getId() %>">VIEW NOW</a>
							<div class="clearfix"> </div>
						</div>
					</a>
					
					<div class="galy-info">
						
						<!-- s -->
						<table border="0" width="100%">
						  <tr>
						    <td colspan="2"><b style="color: black;"><%=goods.getGoodname() %></b></td>
						  </tr>
						  <tr>
						    <td align="right" style="padding-right: 25px;">借阅次数:<%=goods.getCs() %></td>
						  </tr>
						</table>
						
						<!-- e -->
					</div>
				</div>
				<%} %>
			</div>	
	<!--//gallery-->
	
									</div>
					</div>
				</div>
				<div align="center" >${page.info }</div>
</div></div></div>
	<jsp:include page="foot.jsp"></jsp:include>
  </body>
</html>
